package org.icress.fusion.moc

class AjaxService {

    static transactional = true
    
    def moctb(input) {
        //def result = Tb.findAllByTb001Ilike("%${input}%", [max:10, sort:"tb001", order:"asc", offset:0])
        def result = Tb.withCriteria{
            projections{
                property("id")
                property("tb001")
            }
            ilike("tb001", "%"+input + "%")
            maxResults(10)
            order("tb001", "asc")
        }
        return result
    }
    
    def mocti(input) {
        
        def result = Ti.withCriteria{
            projections{
                property("id")
                property("ti001")
                property("ti002")
            }
            ilike("ti001", "%${input}%")
            maxResults(10)
            order("ti001", "asc")
        }
        
        return result
        
    }

    def workshop() {
        def result = Tb.withCriteria {
            projections {
                groupProperty("tb010")
            }
            order('tb010', 'asc')
        }
        //2012-02-06 增加班组
        result.push('品质部')
        result.push('营销中心')
        result.push('研发中心')
        result.push('采购部')
        result.push('设备部')
        return result
    }
}
